Optimal. Leaf size=160 \[ \frac {1}{8} a^2 (7 A+6 B) x+\frac {a^2 (10 A+9 B) \sin (c+d x)}{5 d}+\frac {a^2 (7 A+6 B) \cos (c+d x) \sin (c+d x)}{8 d}+\frac {a^2 (5 A+6 B) \cos ^3(c+d x) \sin (c+d x)}{20 d}+\frac {B \cos ^3(c+d x) \left (a^2+a^2 \cos (c+d x)\right ) \sin (c+d x)}{5 d}-\frac {a^2 (10 A+9 B) \sin ^3(c+d x)}{15 d} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.20, antiderivative size = 160, normalized size of antiderivative = 1.00, number of steps
used = 8, number of rules used = 7, integrand size = 31, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.226, Rules used = {3055, 3047,
3102, 2827, 2715, 8, 2713} \begin {gather*} -\frac {a^2 (10 A+9 B) \sin ^3(c+d x)}{15 d}+\frac {a^2 (10 A+9 B) \sin (c+d x)}{5 d}+\frac {a^2 (5 A+6 B) \sin (c+d x) \cos ^3(c+d x)}{20 d}+\frac {a^2 (7 A+6 B) \sin (c+d x) \cos (c+d x)}{8 d}+\frac {1}{8} a^2 x (7 A+6 B)+\frac {B \sin (c+d x) \cos ^3(c+d x) \left (a^2 \cos (c+d x)+a^2\right )}{5 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 8
Rule 2713
Rule 2715
Rule 2827
Rule 3047
Rule 3055
Rule 3102
Rubi steps
\begin {align*} \int \cos ^2(c+d x) (a+a \cos (c+d x))^2 (A+B \cos (c+d x)) \, dx &=\frac {B \cos ^3(c+d x) \left (a^2+a^2 \cos (c+d x)\right ) \sin (c+d x)}{5 d}+\frac {1}{5} \int \cos ^2(c+d x) (a+a \cos (c+d x)) (a (5 A+3 B)+a (5 A+6 B) \cos (c+d x)) \, dx\\ &=\frac {B \cos ^3(c+d x) \left (a^2+a^2 \cos (c+d x)\right ) \sin (c+d x)}{5 d}+\frac {1}{5} \int \cos ^2(c+d x) \left (a^2 (5 A+3 B)+\left (a^2 (5 A+3 B)+a^2 (5 A+6 B)\right ) \cos (c+d x)+a^2 (5 A+6 B) \cos ^2(c+d x)\right ) \, dx\\ &=\frac {a^2 (5 A+6 B) \cos ^3(c+d x) \sin (c+d x)}{20 d}+\frac {B \cos ^3(c+d x) \left (a^2+a^2 \cos (c+d x)\right ) \sin (c+d x)}{5 d}+\frac {1}{20} \int \cos ^2(c+d x) \left (5 a^2 (7 A+6 B)+4 a^2 (10 A+9 B) \cos (c+d x)\right ) \, dx\\ &=\frac {a^2 (5 A+6 B) \cos ^3(c+d x) \sin (c+d x)}{20 d}+\frac {B \cos ^3(c+d x) \left (a^2+a^2 \cos (c+d x)\right ) \sin (c+d x)}{5 d}+\frac {1}{4} \left (a^2 (7 A+6 B)\right ) \int \cos ^2(c+d x) \, dx+\frac {1}{5} \left (a^2 (10 A+9 B)\right ) \int \cos ^3(c+d x) \, dx\\ &=\frac {a^2 (7 A+6 B) \cos (c+d x) \sin (c+d x)}{8 d}+\frac {a^2 (5 A+6 B) \cos ^3(c+d x) \sin (c+d x)}{20 d}+\frac {B \cos ^3(c+d x) \left (a^2+a^2 \cos (c+d x)\right ) \sin (c+d x)}{5 d}+\frac {1}{8} \left (a^2 (7 A+6 B)\right ) \int 1 \, dx-\frac {\left (a^2 (10 A+9 B)\right ) \text {Subst}\left (\int \left (1-x^2\right ) \, dx,x,-\sin (c+d x)\right )}{5 d}\\ &=\frac {1}{8} a^2 (7 A+6 B) x+\frac {a^2 (10 A+9 B) \sin (c+d x)}{5 d}+\frac {a^2 (7 A+6 B) \cos (c+d x) \sin (c+d x)}{8 d}+\frac {a^2 (5 A+6 B) \cos ^3(c+d x) \sin (c+d x)}{20 d}+\frac {B \cos ^3(c+d x) \left (a^2+a^2 \cos (c+d x)\right ) \sin (c+d x)}{5 d}-\frac {a^2 (10 A+9 B) \sin ^3(c+d x)}{15 d}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.47, size = 108, normalized size = 0.68 \begin {gather*} \frac {a^2 (360 B c+420 A d x+360 B d x+60 (12 A+11 B) \sin (c+d x)+240 (A+B) \sin (2 (c+d x))+80 A \sin (3 (c+d x))+90 B \sin (3 (c+d x))+15 A \sin (4 (c+d x))+30 B \sin (4 (c+d x))+6 B \sin (5 (c+d x)))}{480 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.17, size = 186, normalized size = 1.16
method | result | size |
risch | \(\frac {7 a^{2} x A}{8}+\frac {3 a^{2} B x}{4}+\frac {3 \sin \left (d x +c \right ) a^{2} A}{2 d}+\frac {11 \sin \left (d x +c \right ) B \,a^{2}}{8 d}+\frac {\sin \left (5 d x +5 c \right ) B \,a^{2}}{80 d}+\frac {\sin \left (4 d x +4 c \right ) a^{2} A}{32 d}+\frac {\sin \left (4 d x +4 c \right ) B \,a^{2}}{16 d}+\frac {\sin \left (3 d x +3 c \right ) a^{2} A}{6 d}+\frac {3 \sin \left (3 d x +3 c \right ) B \,a^{2}}{16 d}+\frac {\sin \left (2 d x +2 c \right ) a^{2} A}{2 d}+\frac {\sin \left (2 d x +2 c \right ) B \,a^{2}}{2 d}\) | \(172\) |
derivativedivides | \(\frac {a^{2} A \left (\frac {\left (\cos ^{3}\left (d x +c \right )+\frac {3 \cos \left (d x +c \right )}{2}\right ) \sin \left (d x +c \right )}{4}+\frac {3 d x}{8}+\frac {3 c}{8}\right )+\frac {B \,a^{2} \left (\frac {8}{3}+\cos ^{4}\left (d x +c \right )+\frac {4 \left (\cos ^{2}\left (d x +c \right )\right )}{3}\right ) \sin \left (d x +c \right )}{5}+\frac {2 a^{2} A \left (\cos ^{2}\left (d x +c \right )+2\right ) \sin \left (d x +c \right )}{3}+2 B \,a^{2} \left (\frac {\left (\cos ^{3}\left (d x +c \right )+\frac {3 \cos \left (d x +c \right )}{2}\right ) \sin \left (d x +c \right )}{4}+\frac {3 d x}{8}+\frac {3 c}{8}\right )+a^{2} A \left (\frac {\sin \left (d x +c \right ) \cos \left (d x +c \right )}{2}+\frac {d x}{2}+\frac {c}{2}\right )+\frac {B \,a^{2} \left (\cos ^{2}\left (d x +c \right )+2\right ) \sin \left (d x +c \right )}{3}}{d}\) | \(186\) |
default | \(\frac {a^{2} A \left (\frac {\left (\cos ^{3}\left (d x +c \right )+\frac {3 \cos \left (d x +c \right )}{2}\right ) \sin \left (d x +c \right )}{4}+\frac {3 d x}{8}+\frac {3 c}{8}\right )+\frac {B \,a^{2} \left (\frac {8}{3}+\cos ^{4}\left (d x +c \right )+\frac {4 \left (\cos ^{2}\left (d x +c \right )\right )}{3}\right ) \sin \left (d x +c \right )}{5}+\frac {2 a^{2} A \left (\cos ^{2}\left (d x +c \right )+2\right ) \sin \left (d x +c \right )}{3}+2 B \,a^{2} \left (\frac {\left (\cos ^{3}\left (d x +c \right )+\frac {3 \cos \left (d x +c \right )}{2}\right ) \sin \left (d x +c \right )}{4}+\frac {3 d x}{8}+\frac {3 c}{8}\right )+a^{2} A \left (\frac {\sin \left (d x +c \right ) \cos \left (d x +c \right )}{2}+\frac {d x}{2}+\frac {c}{2}\right )+\frac {B \,a^{2} \left (\cos ^{2}\left (d x +c \right )+2\right ) \sin \left (d x +c \right )}{3}}{d}\) | \(186\) |
norman | \(\frac {\frac {a^{2} \left (7 A +6 B \right ) x}{8}+\frac {7 a^{2} \left (7 A +6 B \right ) \left (\tan ^{7}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{6 d}+\frac {a^{2} \left (7 A +6 B \right ) \left (\tan ^{9}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{4 d}+\frac {5 a^{2} \left (7 A +6 B \right ) x \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{8}+\frac {5 a^{2} \left (7 A +6 B \right ) x \left (\tan ^{4}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{4}+\frac {5 a^{2} \left (7 A +6 B \right ) x \left (\tan ^{6}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{4}+\frac {5 a^{2} \left (7 A +6 B \right ) x \left (\tan ^{8}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{8}+\frac {a^{2} \left (7 A +6 B \right ) x \left (\tan ^{10}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{8}+\frac {a^{2} \left (25 A +26 B \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{4 d}+\frac {8 a^{2} \left (25 A +27 B \right ) \left (\tan ^{5}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{15 d}+\frac {a^{2} \left (79 A +54 B \right ) \left (\tan ^{3}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{6 d}}{\left (1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )^{5}}\) | \(279\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.27, size = 178, normalized size = 1.11 \begin {gather*} -\frac {320 \, {\left (\sin \left (d x + c\right )^{3} - 3 \, \sin \left (d x + c\right )\right )} A a^{2} - 15 \, {\left (12 \, d x + 12 \, c + \sin \left (4 \, d x + 4 \, c\right ) + 8 \, \sin \left (2 \, d x + 2 \, c\right )\right )} A a^{2} - 120 \, {\left (2 \, d x + 2 \, c + \sin \left (2 \, d x + 2 \, c\right )\right )} A a^{2} - 32 \, {\left (3 \, \sin \left (d x + c\right )^{5} - 10 \, \sin \left (d x + c\right )^{3} + 15 \, \sin \left (d x + c\right )\right )} B a^{2} + 160 \, {\left (\sin \left (d x + c\right )^{3} - 3 \, \sin \left (d x + c\right )\right )} B a^{2} - 30 \, {\left (12 \, d x + 12 \, c + \sin \left (4 \, d x + 4 \, c\right ) + 8 \, \sin \left (2 \, d x + 2 \, c\right )\right )} B a^{2}}{480 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.36, size = 110, normalized size = 0.69 \begin {gather*} \frac {15 \, {\left (7 \, A + 6 \, B\right )} a^{2} d x + {\left (24 \, B a^{2} \cos \left (d x + c\right )^{4} + 30 \, {\left (A + 2 \, B\right )} a^{2} \cos \left (d x + c\right )^{3} + 8 \, {\left (10 \, A + 9 \, B\right )} a^{2} \cos \left (d x + c\right )^{2} + 15 \, {\left (7 \, A + 6 \, B\right )} a^{2} \cos \left (d x + c\right ) + 16 \, {\left (10 \, A + 9 \, B\right )} a^{2}\right )} \sin \left (d x + c\right )}{120 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 459 vs.
\(2 (144) = 288\).
time = 0.35, size = 459, normalized size = 2.87 \begin {gather*} \begin {cases} \frac {3 A a^{2} x \sin ^{4}{\left (c + d x \right )}}{8} + \frac {3 A a^{2} x \sin ^{2}{\left (c + d x \right )} \cos ^{2}{\left (c + d x \right )}}{4} + \frac {A a^{2} x \sin ^{2}{\left (c + d x \right )}}{2} + \frac {3 A a^{2} x \cos ^{4}{\left (c + d x \right )}}{8} + \frac {A a^{2} x \cos ^{2}{\left (c + d x \right )}}{2} + \frac {3 A a^{2} \sin ^{3}{\left (c + d x \right )} \cos {\left (c + d x \right )}}{8 d} + \frac {4 A a^{2} \sin ^{3}{\left (c + d x \right )}}{3 d} + \frac {5 A a^{2} \sin {\left (c + d x \right )} \cos ^{3}{\left (c + d x \right )}}{8 d} + \frac {2 A a^{2} \sin {\left (c + d x \right )} \cos ^{2}{\left (c + d x \right )}}{d} + \frac {A a^{2} \sin {\left (c + d x \right )} \cos {\left (c + d x \right )}}{2 d} + \frac {3 B a^{2} x \sin ^{4}{\left (c + d x \right )}}{4} + \frac {3 B a^{2} x \sin ^{2}{\left (c + d x \right )} \cos ^{2}{\left (c + d x \right )}}{2} + \frac {3 B a^{2} x \cos ^{4}{\left (c + d x \right )}}{4} + \frac {8 B a^{2} \sin ^{5}{\left (c + d x \right )}}{15 d} + \frac {4 B a^{2} \sin ^{3}{\left (c + d x \right )} \cos ^{2}{\left (c + d x \right )}}{3 d} + \frac {3 B a^{2} \sin ^{3}{\left (c + d x \right )} \cos {\left (c + d x \right )}}{4 d} + \frac {2 B a^{2} \sin ^{3}{\left (c + d x \right )}}{3 d} + \frac {B a^{2} \sin {\left (c + d x \right )} \cos ^{4}{\left (c + d x \right )}}{d} + \frac {5 B a^{2} \sin {\left (c + d x \right )} \cos ^{3}{\left (c + d x \right )}}{4 d} + \frac {B a^{2} \sin {\left (c + d x \right )} \cos ^{2}{\left (c + d x \right )}}{d} & \text {for}\: d \neq 0 \\x \left (A + B \cos {\left (c \right )}\right ) \left (a \cos {\left (c \right )} + a\right )^{2} \cos ^{2}{\left (c \right )} & \text {otherwise} \end {cases} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.44, size = 137, normalized size = 0.86 \begin {gather*} \frac {B a^{2} \sin \left (5 \, d x + 5 \, c\right )}{80 \, d} + \frac {1}{8} \, {\left (7 \, A a^{2} + 6 \, B a^{2}\right )} x + \frac {{\left (A a^{2} + 2 \, B a^{2}\right )} \sin \left (4 \, d x + 4 \, c\right )}{32 \, d} + \frac {{\left (8 \, A a^{2} + 9 \, B a^{2}\right )} \sin \left (3 \, d x + 3 \, c\right )}{48 \, d} + \frac {{\left (A a^{2} + B a^{2}\right )} \sin \left (2 \, d x + 2 \, c\right )}{2 \, d} + \frac {{\left (12 \, A a^{2} + 11 \, B a^{2}\right )} \sin \left (d x + c\right )}{8 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 1.50, size = 277, normalized size = 1.73 \begin {gather*} \frac {\left (\frac {7\,A\,a^2}{4}+\frac {3\,B\,a^2}{2}\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^9+\left (\frac {49\,A\,a^2}{6}+7\,B\,a^2\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^7+\left (\frac {40\,A\,a^2}{3}+\frac {72\,B\,a^2}{5}\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^5+\left (\frac {79\,A\,a^2}{6}+9\,B\,a^2\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3+\left (\frac {25\,A\,a^2}{4}+\frac {13\,B\,a^2}{2}\right )\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{d\,\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^{10}+5\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^8+10\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^6+10\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4+5\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+1\right )}-\frac {a^2\,\left (7\,A+6\,B\right )\,\left (\mathrm {atan}\left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )-\frac {d\,x}{2}\right )}{4\,d}+\frac {a^2\,\mathrm {atan}\left (\frac {a^2\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (7\,A+6\,B\right )}{4\,\left (\frac {7\,A\,a^2}{4}+\frac {3\,B\,a^2}{2}\right )}\right )\,\left (7\,A+6\,B\right )}{4\,d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________